package com.community.controller;

import com.community.service.MemberService;
import com.community.util.Result;
import com.community.util.Search;
import com.feng.fengDUtil.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping(value = "/member")
public class MemberAction {
    @Autowired
    private MemberService memberService;

    @RequestMapping(value = "/list")
    public Result list(Page page, Search search) {
        memberService.query(page,search);
        return Result.success(page);
    }

    @RequestMapping(value = "/uploadMember", method = RequestMethod.POST)
    public Result uploadMember(MultipartFile file){
        try {
            return Result.success(memberService.uploadMember(file));
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error(e.getMessage());
        }
    }

}
